package main;

import java.util.List;
import models.*;
//import models.mappers.*;
import voidlib.*;
/**
 * @author nevidimov
 */
public class AdminController extends VoidController {

    public void accountsAction() {
        
        if (this.isPostRequest()) {
            String login = this.request.getParameter("login");
            String password = this.request.getParameter("password");
            UserRole role = UserRole.valueOf(this.request.getParameter("role"));
            int balance = Integer.parseInt(this.request.getParameter("balance"));
            String title = this.request.getParameter("title");
            
            User user = new User(login, password, title, balance, role);
            user.save();
        }
        
        List<User> accounts = new User().getMapper().fetchAll();
        this.view.put("accounts", accounts);
        this.initModelAndView();
    }
    
    public void addAccountAction() {
        
        this.initModelAndView();
    }

}
